#include "Log.h"
#include <boost/date_time/posix_time/posix_time.hpp>

namespace cgi{

CLog::CLog(void)
{
}


CLog::~CLog(void)
{
	if(m_log.is_open())
	{
		m_log.flush();
		m_log.close();
	}
}

void CLog::init(const std::string& logPath)
{
	if(!m_log.is_open())
	{
		m_log.open(logPath.c_str(), std::ios::app);
	}
}

void CLog::log(const std::string& sLog)
{
	std::string strTime = boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time()); 
	if(m_log.is_open())
	{
		m_log<<strTime << "||"<< sLog<<std::endl;
	}
}

}